package com.library.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;


/*
* 图书类别类
* */

@Entity
@Table(name="bookClass")
public class BookClass {
	private Integer bookClassId;		//图书类别ID
	private String name;			//图书类别名称
	private Set<Book> books = new HashSet<Book>();	//图书
	private Set<StaffSearch> searchs =new HashSet<StaffSearch>();	//搜索记录
	private Set<Statistic> statistics = new HashSet<Statistic>();	//统计记录

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Integer getBookClassId() {
		return bookClassId;
	}
	public void setBookClassId(Integer bookClassId) {
		this.bookClassId = bookClassId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	@OneToMany(cascade=CascadeType.PERSIST)            //指定一对多关系
	@JoinColumn(name="bookClassId")                       //指定与本类主键所对应的外表的外键
	public Set<Book> getBooks() {
		return books;
	}

	public void setBooks(Set<Book> books) {
		this.books = books;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="bookClassId")                       //指定与本类主键所对应的外表的外键
	public Set<StaffSearch> getSearchs() {
		return searchs;
	}
	public void setSearchs(Set<StaffSearch> searchs) {
		this.searchs = searchs;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="bookClassId")                       //指定与本类主键所对应的外表的外键
	public Set<Statistic> getStatistics() {
		return statistics;
	}
	public void setStatistics(Set<Statistic> statistics) {
		this.statistics = statistics;
	}
}
